package com.icode.core.dto.manager;

import com.icode.core.model.house.HouseBaseArea;
import com.icode.core.model.manage.SellManager;

import java.util.ArrayList;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: xianfei
 * Date: 15-8-15
 * Time: 上午10:43
 * To change this template use File | Settings | File Templates.
 */
public class SellManagerDTO {

    private String guid;
    private String area;
    private String gold;
    private String busy;
    private String slack;
    private String common;
    private String areaAsString;

    public SellManagerDTO() {
    }

    public SellManagerDTO(String guid, String area, String gold, String busy, String slack, String common, String areaAsString) {
        this.guid = guid;
        this.area = area;
        this.gold = gold;
        this.busy = busy;
        this.slack = slack;
        this.common = common;
        this.areaAsString = areaAsString;
    }

    public static SellManagerDTO toDTO(SellManager sellManager) {
        return new SellManagerDTO(sellManager.guid(), sellManager.houseBaseArea().getValue(), String.valueOf(sellManager.gold()), String.valueOf(sellManager.busy()), String.valueOf(sellManager.slack()), String.valueOf(sellManager.common()), sellManager.houseBaseArea().getLabel());
    }

    public static List<SellManagerDTO> toDTOs(List<SellManager> sellManagers) {
        List<SellManagerDTO> sellManagerDTOs = new ArrayList<>();
        for (SellManager s : sellManagers) {
            sellManagerDTOs.add(toDTO(s));
        }
        return sellManagerDTOs;
    }

    public static SellManager toSellManager(SellManagerDTO sellManagerDTO) {
        return new SellManager(HouseBaseArea.valueOf(sellManagerDTO.getArea()), Integer.parseInt(sellManagerDTO.getGold()), Integer.parseInt(sellManagerDTO.getBusy()), Integer.parseInt(sellManagerDTO.getSlack()), Integer.parseInt(sellManagerDTO.getCommon()));
    }

    public String getGuid() {
        return guid;
    }

    public void setGuid(String guid) {
        this.guid = guid;
    }

    public String getArea() {
        return area;
    }

    public void setArea(String area) {
        this.area = area;
    }

    public String getGold() {
        return gold;
    }

    public String getAreaAsString() {
        return areaAsString;
    }

    public void setAreaAsString(String areaAsString) {
        this.areaAsString = areaAsString;
    }

    public void setGold(String gold) {
        this.gold = gold;
    }

    public String getBusy() {
        return busy;
    }

    public void setBusy(String busy) {
        this.busy = busy;
    }

    public String getSlack() {
        return slack;
    }

    public void setSlack(String slack) {
        this.slack = slack;
    }

    public String getCommon() {
        return common;
    }

    public void setCommon(String common) {
        this.common = common;
    }
}
